package com.example.diagnodroid.connexion;

import java.util.List;

import android.app.Activity;
import android.net.wifi.ScanResult;
import android.os.Bundle;
import android.widget.TextView;

import com.example.diagnodroid.R;

public class WifiActivity extends Activity {

	WifiTracker wifi;
	TextView wifiInfoText;
	
	@Override
	public void onCreate(Bundle savedInstanceState) {
		
		setContentView(R.layout.wifi_layout);

		wifiInfoText = (TextView)findViewById(R.id.wifi_info);
			
		wifi = new WifiTracker(this);

		if(wifi.isWifiEnabled){
			
			wifiInfoText.append("\n Information sur le réseau actuel : ");
			wifiInfoText.append("\n  nom : " + wifi.info.getSSID() + "\n  adresse IP : " + wifi.info.getIpAddress() + "\n  adresse MAC : " + wifi.info.getMacAddress());
			
			List<ScanResult> wifi_dispos = wifi.wifiManager.getScanResults();			
			wifiInfoText.append("\n\n WiFi disponibles : ");
			for(ScanResult wifi_dispo : wifi_dispos){
				wifiInfoText.append("\n nom : " + wifi_dispo.SSID + "\n adresse : " + wifi_dispo.BSSID + "\n frequence : " + wifi_dispo.frequency + "\n");
			}		
			
		} else {
			wifi.showSettingsAlert();
		}

		super.onCreate(savedInstanceState);
			
		
	}
		
	@Override
	protected void onResume() {
		super.onResume();
	}

	@Override
	protected void onStop() {
		super.onStop();
	}
}
